﻿using System.Collections.Generic;
using Lari.DataAccess;
using Lari.Services.Data;
using Lari.Services.ViewModel;

namespace Lari.Services.Implementation
{
    public class MasterManager : LariService
    {
        #region Genders
        public List<Gender> Genders()
        {
            using (var db = new LariDbContext(false))
            {
                return MasterDataAccess.Genders(db);
            }
        }

        public Gender Genders(string genderCode)
        {
            using (var db = new LariDbContext(false))
            {
                return MasterDataAccess.Genders(genderCode, db);
            }
        }

        public void Update(GenderModel model)
        {
            using (var db = new LariDbContext(false))
            {
                MasterDataAccess.Update(model, db);
            }
        }

        public void Save(GenderModel model)
        {
            using (var db = new LariDbContext(false))
            {
                MasterDataAccess.Save(model, db);
            }
        }
        #endregion

        #region Country
        public List<Country> Countries()
        {
            using (var db = new LariDbContext(false))
            {
                return MasterDataAccess.Countries(db);
            }
        }

        public Country Country(string code)
        {
            using (var db = new LariDbContext(false))
            {
                return MasterDataAccess.Country(db, code);
            }
        }

        public void Update(CountryModal model)
        {
            using (var db = new LariDbContext(false))
            {
                MasterDataAccess.Update(db, model);
            }
        }

        public void Save(CountryModal model)
        {
            using (var db = new LariDbContext(false))
            {
                MasterDataAccess.Save(db, model);
            }
        }
        #endregion

        #region States
        public List<State> States()
        {
            using (var db = new LariDbContext(false))
            {
                return MasterDataAccess.States(db);
            }
        }

        public State State(string code)
        {
            using (var db = new LariDbContext(false))
            {
                return MasterDataAccess.State(db, code);
            }
        }

        public void Update(StateModel model)
        {
            using (var db = new LariDbContext(false))
            {
                MasterDataAccess.Update(db, model);
            }
        }

        public void Save(StateModel model)
        {
            using (var db = new LariDbContext(false))
            {
                MasterDataAccess.Save(db, model);
            }
        }
        #endregion

        #region Religions
        public List<Religion> Religions()
        {
            using (var db = new LariDbContext(false))
            {
                return MasterDataAccess.Rligions(db);
            }
        }

        public Religion Religion(string code)
        {
            using (var db = new LariDbContext(false))
            {
                return MasterDataAccess.Religion(db, code);
            }
        }

        public void Update(ReligionModel model)
        {
            using (var db = new LariDbContext(false))
            {
                MasterDataAccess.Update(model, db);
            }
        }

        public void Save(ReligionModel model)
        {
            using (var db = new LariDbContext(false))
            {
                MasterDataAccess.Save(model, db);
            }
        }
        #endregion

        #region MaritalStatus
        public List<MaritalStatus> MaritalStatuses()
        {
            using (var db = new LariDbContext(false))
            {
                return MasterDataAccess.MaritalStatuses(db);
            }
        }

        public MaritalStatus MaritalStatus(string id)
        {
            using (var db = new LariDbContext(false))
            {
                return MasterDataAccess.MaritalStatus(db, id);
            }
        }

        public void Update(MaritalStatusModel model)
        {
            using (var db = new LariDbContext(false))
            {
                MasterDataAccess.Update(db, model);
            }
        }

        public void Save(MaritalStatusModel model)
        {
            using (var db = new LariDbContext(false))
            {
                MasterDataAccess.Save(db, model);
            }
        }
        #endregion

        #region EmployeeType
        public List<EmployeeType> EmployeeTypes()
        {
            using (var db = new LariDbContext(false))
            {
                return MasterDataAccess.EmployeeTypes(db);
            }
        }

        public void Update(EmployeeTypeModel employeeTypeModel)
        {
            using (var db = new LariDbContext(false))
            {
                MasterDataAccess.Update(db, employeeTypeModel);
            }
        }

        public void Save(EmployeeTypeModel employeeTypeModel)
        {
            using (var db = new LariDbContext(false))
            {
                MasterDataAccess.Save(db, employeeTypeModel);
            }
        }
        public EmployeeType EmployeeType(int id)
        {
            using (var db = new LariDbContext(false))
            {
                return MasterDataAccess.EmployeeType(id, db);
            }
        }
        #endregion

        #region Titles
        public List<Title> Titles()
        {
            using (var db = new LariDbContext(false))
            {
                return MasterDataAccess.Titles(db);
            }
        }

        public void Update(TitleModel titleModel)
        {
            using (var db = new LariDbContext(false))
            {
                MasterDataAccess.Update(db, titleModel);
            }
        }

        public void Save(TitleModel titleModel)
        {
            using (var db = new LariDbContext(false))
            {
                MasterDataAccess.Save(db, titleModel);
            }
        }
        public Title Title(int id)
        {
            using (var db = new LariDbContext(false))
            {
                return MasterDataAccess.Title(db, id);
            }
        }
        #endregion

        #region Bloodgroups
        public List<Bloodgroup> Bloodgroups()
        {
            using (var db = new LariDbContext(false))
            {
                return MasterDataAccess.Bloodgroups(db);
            }


        }
        public Bloodgroup Bloodgroup(int id)
        {
            using (var db = new LariDbContext(false))
            {
                return MasterDataAccess.Bloodgroup(db, id);
            } 
        }

        public void Update(BloodgroupModel bloodgroupModel)
        {
            using (var db = new LariDbContext(false))
            {
                MasterDataAccess.Update(db, bloodgroupModel);
            }
        }

        public void Save(BloodgroupModel bloodgroupModel)
        {
            using (var db = new LariDbContext(false))
            {
                MasterDataAccess.Save(db, bloodgroupModel);
            }
        }
        #endregion

        #region Designation
        public List<Designation> Designations()
        {
            using (var db = new LariDbContext(false))
            {
                return MasterDataAccess.Designations(db);
            }

        }

        public void Update(DesignationModel designationModel)
        {
            using (var db = new LariDbContext(false))
            {
                MasterDataAccess.Update(db, designationModel);
            }
        }

        public void Save(DesignationModel designationModel)
        {
            using (var db = new LariDbContext(false))
            {
                MasterDataAccess.Save(db, designationModel);
            }
        }
        #endregion

        #region Department - designation - specialization
        public List<Department> Departments()
        {
            using (var db = new LariDbContext(false))
            {
                return MasterDataAccess.Departments(db);
            }

        }

        public Department Department(int id, bool fetchSpecialization = false)
        {
            using (var db = new LariDbContext(false))
            {
                return MasterDataAccess.Department(db, id, fetchSpecialization);
            }
        }

        public void Update(DepartmentModel departmentModel)
        {
            using (var db = new LariDbContext(false))
            {
                MasterDataAccess.Update(db, departmentModel);
            }
        }

        public void Save(DepartmentModel departmentModel)
        {
            using (var db = new LariDbContext(false))
            {
                MasterDataAccess.Save(db, departmentModel);
            }
        }

        public void Update(DepartmentDesignationModel model)
        {
            using (var db = new LariDbContext(false))
            {
                MasterDataAccess.Save(db, model);
            }
        }

        public void RemoveDesignationMapping(int departmentId)
        {
            using (var db = new LariDbContext(false))
            {
                MasterDataAccess.RemoveDesignationMapping(db, departmentId);
            }
        }

        public void SaveSpecialization(int departmentId, string specialization)
        {
            using (var db = new LariDbContext(false))
            {
                MasterDataAccess.SaveSpecialization(db, departmentId, specialization);
            }
        }

        public Specialization Specilization(int specilizationId)
        {
            using (var db = new LariDbContext(false))
            {
                return MasterDataAccess.Specilization(specilizationId, db);
            }
        }

        public void ModifySpcealization(string specializationName, int specializationId, int departmentId)
        {
            using (var db = new LariDbContext(false))
            {
                MasterDataAccess.ModifySpcealization(departmentId, specializationId, specializationName, db);
            }
        }
        

        public int SpecilizationDelete(int specializationId)
        {
            using (var db = new LariDbContext(false))
            {
                return MasterDataAccess.SpecilizationDelete(specializationId, db);
            }
        }

        public Designation Designation(int id)
        {
            using (var db = new LariDbContext(false))
            {
                return MasterDataAccess.Designation(id, db);
            }
        }
        #endregion

        public List<Qualification> Qualifications(int currentPage, ref int totalPageCount)
        {
            using (var db = new LariDbContext(false))
            {
                return MasterDataAccess.Qualifications(db, currentPage, ref totalPageCount);
            }
        }

        public Qualification Qualification(int id)
        {
            using (var db = new LariDbContext(false))
            {
                return MasterDataAccess.Qualification(db,id);
            }
        }

        public List<Qualification> QualificationsAll()
        {
            using (var db = new LariDbContext(false))
            {
                return MasterDataAccess.QualificationsAll(db);
            }
        }
        public void Save(QualificationModel model)
        {
            using (var db = new LariDbContext(false))
            {
                MasterDataAccess.Save(model,db);
            }
        }
        public void Update(QualificationModel model)
        {
            using (var db = new LariDbContext(false))
            {
                MasterDataAccess.Update(model, db);
            }
        }
    }
}
